package net.homelinux.chaoswg.io.renga.core.gui.operations.reader;

import net.homelinux.chaoswg.io.higherorderfunctions.AbstractUnaryFunction;
import net.homelinux.chaoswg.io.renga.core.gui.operations.visualisations.SplitBlockVisualisation;
import net.homelinux.chaoswg.io.renga.core.gui.operations.visualisations.Visualisation;

import org.jdom.Element;

public class SplitBoxVisualisationReader extends AbstractUnaryFunction<Visualisation, Element> implements VisualisationReader {

    public Visualisation apply(final Element arg0) throws IllegalArgumentException {
        final int x = Integer.parseInt(arg0.getChildText("x"));
        final int y = Integer.parseInt(arg0.getChildText("y"));
        final int width = Integer.parseInt(arg0.getChildText("width"));
        final int height = Integer.parseInt(arg0.getChildText("height"));
        final int split = Integer.parseInt(arg0.getChildText("split"));
        
        return new SplitBlockVisualisation (x, y, width, height, split);
    }
}
